import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';

/**
 * 模态框工具
 */
export const $modal = {
  msgSuccess: (message: string) => {
    ElMessage.success(message);
  },
  msgError: (message: string) => {
    ElMessage.error(message);
  },
  msgInfo: (message: string) => {
    ElMessage.info(message);
  },
  msgWarning: (message: string) => {
    ElMessage.warning(message);
  },
  confirm: (message: string, title?: string) => {
    return ElMessageBox.confirm(message, title || '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    });
  },
  msgLoading: (message: string) => {
    return ElLoading.service({
      lock: true,
      text: '', // 不显示文本，保持统一的加载体验
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    });
  },
  msgClose: (loading: any) => {
    loading.close();
  }
};